home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / archiver / unix / unz50p1.zoo / unzip.h < prev    next >
C/C++ Source or Header  |  1993-01-11  |  43KB  |  1,244 lines

  1. /*---------------------------------------------------------------------------
  2.  
  3.   unzip.h
  4.  
  5.   This header file is used by all of the unzip source files.  Its contents
  6.   are divided into seven more-or-less separate sections:  predefined macros,
  7.   OS-dependent includes, (mostly) OS-independent defines, typedefs, function 
  8.   prototypes (or "prototypes," in the case of non-ANSI compilers), macros, 
  9.   and global-variable declarations.
  10.  
  11.   ---------------------------------------------------------------------------*/
  12.  
  13.  
  14.  
  15. /*****************************************/
  16. /*  Predefined, Machine-specific Macros  */
  17. /*****************************************/
  18.  
  19. #if (defined(__GO32__) && defined(unix))   /* DOS extender */
  20. #  undef unix
  21. #endif
  22.  
  23. #if defined(unix) || defined(__convexc__) || defined(M_XENIX)
  24. #  ifndef UNIX
  25. #    define UNIX
  26. #  endif /* !UNIX */
  27. #endif /* unix || __convexc__ || M_XENIX */
  28.  
  29. /* Much of the following is swiped from zip's tailor.h: */
  30.  
  31. /* define MSDOS for Turbo C (unless OS/2) and Power C as well as Microsoft C */
  32. #ifdef __POWERC
  33. #  define __TURBOC__
  34. #  define MSDOS
  35. #endif /* __POWERC */
  36. #if (defined(__TURBOC__) && defined(__MSDOS__) && !defined(MSDOS))
  37. #  define MSDOS
  38. #endif
  39.  
  40. /* use prototypes and ANSI libraries if __STDC__, or Microsoft or Borland C,
  41.  * or Silicon Graphics, or Convex, or IBM C Set/2, or GNU gcc under emx, or
  42.  * or Watcom C, or Macintosh, or Windows NT.
  43.  */
  44. #if (__STDC__ || defined(MSDOS) || defined(sgi) || defined(CONVEX))
  45. #  ifndef PROTO
  46. #    define PROTO
  47. #  endif
  48. #  define MODERN
  49. #endif
  50. #if (defined(__IBMC__) || defined(__EMX__) || defined(__WATCOMC__))
  51. #  ifndef PROTO
  52. #    define PROTO
  53. #  endif
  54. #  define MODERN
  55. #endif
  56. #if (defined(THINK_C) || defined(MPW) || defined(WIN32))
  57. #  ifndef PROTO
  58. #    define PROTO
  59. #  endif
  60. #  define MODERN
  61. #endif
  62.  
  63. /* turn off prototypes if requested */
  64. #if (defined(NOPROTO) && defined(PROTO))
  65. #  undef PROTO
  66. #endif
  67.  
  68. /* used to remove arguments in function prototypes for non-ANSI C */
  69. #ifdef PROTO
  70. #  define OF(a) a
  71. #else /* !PROTO */
  72. #  define OF(a) ()
  73. #endif /* ?PROTO */
  74.  
  75. #if (defined(ultrix) || defined(bsd4_2) || defined(sun) || defined(pyr))
  76. #  if (!defined(BSD) && !defined(__SYSTEM_FIVE) && !defined(SYSV))
  77. #    define BSD
  78. #  endif /* !BSD && !__SYSTEM_FIVE && !SYSV */
  79. #endif /* ultrix || bsd4_2 || sun || pyr */
  80.  
  81. #if (defined(CONVEX) || defined(CRAY) || defined(__SYSTEM_FIVE))
  82. #  ifndef TERMIO
  83. #    define TERMIO
  84. #  endif /* !TERMIO */
  85. #endif /* CONVEX || CRAY || __SYSTEM_FIVE */
  86.  
  87. #ifdef pyr  /* Pyramid */
  88. #  ifndef ZMEM
  89. #    define ZMEM
  90. #  endif /* !ZMEM */
  91. #endif /* pyr */
  92.  
  93. #ifdef CRAY
  94. #  ifdef ZMEM
  95. #    undef ZMEM
  96. #  endif /* ZMEM */
  97. #endif /* CRAY */
  98.  
  99. /* the i386 test below is to catch SCO Unix (which has redefinition
  100.  * warnings if param.h is included), but it probably doesn't hurt if
  101.  * other 386 Unixes get nailed, too...except now that 386BSD and BSDI
  102.  * exist.  Sigh.  <sys/param.h> is mostly included for "BSD", I think.
  103.  * [An alternate fix for SCO Unix is below.]
  104.  */
  105. #if (defined(MINIX) || (defined(i386) && defined(unix)))
  106. #  define NO_PARAM_H
  107. #endif /* MINIX || (i386 && unix) */
  108.  
  109.  
  110.  
  111.  
  112.  
  113. /***************************/
  114. /*  OS-Dependent Includes  */
  115. /***************************/
  116.  
  117. #ifndef MINIX            /* Minix needs it after all the other includes (?) */
  118. #  include <stdio.h>
  119. #endif
  120. #include <ctype.h>       /* skip for VMS, to use tolower() function? */
  121. #include <errno.h>       /* used in mapname() */
  122. #ifndef NO_ERRNO
  123. #  define DECLARE_ERRNO  /* everybody except MSC 6.0, SCO cc, Watcom C/386 */
  124. #endif /* !NO_ERRNO */
  125. #ifdef VMS
  126. #  include <types.h>     /* (placed up here instead of in VMS section below */
  127. #  include <stat.h>      /* because types.h is used in some other headers) */
  128. #else /* !VMS */
  129. #  if !defined(THINK_C) && !defined(MPW)
  130. #    include <sys/types.h>                 /* off_t, time_t, dev_t, ... */
  131. #    include <sys/stat.h>
  132. #  endif /* !THINK_C && !MPW */
  133. #endif /* ?VMS */
  134.  
  135. #ifdef MODERN
  136. #  if (!defined(M_XENIX) && !(defined(__GNUC__) && defined(sun)))
  137. #    include <stddef.h>
  138. #  endif
  139. #  if (!defined(__GNUC__) && !defined(apollo))   /* both define __STDC__ */
  140. #    include <stdlib.h>    /* standard library prototypes, malloc(), etc. */
  141. #  else
  142. #    ifdef __EMX__
  143. #      include <stdlib.h>  /* emx IS gcc but has stdlib.h */
  144. #    endif
  145. #  endif
  146. #  include <string.h>      /* defines strcpy, strcmp, memcpy, etc. */
  147.    typedef size_t extent;
  148.    typedef void voidp;
  149. #else /* !MODERN */
  150.    char *malloc();
  151.    char *strchr(), *strrchr();
  152.    long lseek();
  153.    typedef unsigned int extent;
  154. #  define void int
  155.    typedef char voidp;
  156. #endif /* ?MODERN */
  157.  
  158. /* this include must be down here for SysV.4, for some reason... */
  159. #include <signal.h>      /* used in unzip.c, file_io.c */
  160.  
  161.  
  162.  
  163. /*---------------------------------------------------------------------------
  164.     Next, a word from our Unix (mostly) sponsors:
  165.   ---------------------------------------------------------------------------*/
  166.  
  167. #ifdef UNIX
  168. #  ifdef AMIGA
  169. #    include <libraries/dos.h>
  170. #  else /* !AMIGA */
  171. #    ifndef NO_PARAM_H
  172. #if 0  /* [GRR: this is an alternate fix for SCO's redefinition bug] */
  173. #      ifdef NGROUPS_MAX
  174. #        undef NGROUPS_MAX     /* SCO bug:  defined again in <param.h> */
  175. #      endif /* NGROUPS_MAX */
  176. #endif /* 0 */
  177. #      include <sys/param.h>   /* conflict with <sys/types.h>, some systems? */
  178. #    endif /* !NO_PARAM_H */
  179. #  endif /* ?AMIGA */
  180.  
  181. #  ifndef BSIZE
  182. #    ifdef MINIX
  183. #      define BSIZE   1024
  184. #    else /* !MINIX */
  185. #      define BSIZE   DEV_BSIZE  /* assume common for all Unix systems */
  186. #    endif /* ?MINIX */
  187. #  endif
  188.  
  189. #  ifndef BSD
  190. #    if (!defined(AMIGA) && !defined(MINIX))
  191. #      define NO_MKDIR           /* for mapname() */
  192. #    endif /* !AMIGA && !MINIX */
  193. #    include <time.h>
  194.      struct tm *gmtime(), *localtime();
  195. #  else   /* BSD */
  196. #    include <sys/time.h>
  197. #    include <sys/timeb.h>
  198. #    ifdef _AIX
  199. #      include <time.h>
  200. #    endif
  201. #  endif
  202.  
  203. #else   /* !UNIX */
  204. #  define BSIZE   512               /* disk block size */
  205. #endif /* ?UNIX */
  206.  
  207. #if (defined(V7) || defined(BSD))
  208. #  define strchr    index
  209. #  define strrchr   rindex
  210. #endif
  211.  
  212. /*---------------------------------------------------------------------------
  213.     And now, our MS-DOS and OS/2 corner:
  214.   ---------------------------------------------------------------------------*/
  215.  
  216. #ifdef __TURBOC__
  217. #  define DOS_OS2
  218. #  include <sys/timeb.h>      /* for structure ftime                        */
  219. #  ifndef __BORLANDC__        /* there appears to be a bug (?) in Borland's */
  220. #    include <mem.h>          /*   MEM.H related to __STDC__ and far poin-  */
  221. #  endif                      /*   ters. (dpk)  [mem.h included for memcpy] */
  222. #  include <dos.h>            /* for REGS macro (at least for Turbo C 2.0)  */
  223. #else                         /* NOT Turbo C (or Power C)...                */
  224. #  ifdef MSDOS                /*   but still MS-DOS, so we'll assume it's   */
  225. #    ifndef MSC               /*   Microsoft's compiler and fake the ID, if */
  226. #      define MSC             /*   necessary (it is in 5.0; apparently not  */
  227. #    endif                    /*   in 5.1 and 6.0)                          */
  228. #    include <dos.h>          /* for _dos_setftime()                        */
  229. #  endif
  230. #endif
  231.  
  232. #if (defined(__IBMC__) && defined(__OS2__))
  233. #  define DOS_OS2
  234. #  define S_IFMT 0xF000
  235. #  define timezone _timezone
  236. #endif
  237.  
  238. #ifdef __WATCOMC__
  239. #  define DOS_OS2
  240. #  define __32BIT__
  241. #  ifdef DECLARE_ERRNO
  242. #    undef DECLARE_ERRNO
  243. #  endif
  244. #  undef far
  245. #  define far
  246. #endif
  247.  
  248. #ifdef __EMX__
  249. #  define DOS_OS2
  250. #  define __32BIT__
  251. #  define far
  252. #endif /* __EMX__ */
  253.  
  254. #ifdef MSC                    /* defined for all versions of MSC now         */
  255. #  define DOS_OS2             /* Turbo C under DOS, MSC under DOS or OS/2    */
  256. #  if (defined(_MSC_VER) && (_MSC_VER >= 600))    /* new with 5.1 or 6.0 ... */
  257. #    undef DECLARE_ERRNO      /* errno is now a function in a dynamic link   */
  258. #  endif                      /*   library (or something)--incompatible with */
  259. #endif                        /*   the usual "extern int errno" declaration  */
  260.  
  261. #ifdef DOS_OS2                /* defined for all MS-DOS and OS/2 compilers   */
  262. #  include <io.h>             /* lseek(),